﻿using System.IO.Ports;
using UtilZ.Dotnet.Ex.Communication.Base;

namespace UtilZ.Dotnet.Ex.Communication.Ports
{
    /// <summary>
    /// 串口工厂接口
    /// </summary>
    public class SerialPortFactory : ISerialPortFactory
    {
        /// <summary>
        /// 获取当前计算机串口名数组
        /// </summary>
        /// <returns>当前计算机串口名数组</returns>
        public string[] GetPortNames()
        {
            return SerialPort.GetPortNames();
        }


        /// <summary>
        /// 创建串口
        /// </summary>
        /// <param name="initPara">初始化参数</param>
        /// <returns>串口对象</returns>
        public ISerialPort CreateSerialPort(IClientInitPara initPara)
        {
            return new SerialPortEx(initPara);
        }
    }
}
